﻿#pragma once

#include "../../MirControls/MirImageControl.h"
#include "../../MirControls/MirLabel.h"
#include "../../MirControls/MirButton.h"
#include "../../../Shared/Data/ClientData.h"
#include "../../MirControls/MirControl.h"
#include "../../MirControls/MirTextBox.h"
#include <string>
#include <vector>
#include <any>
#include "../../../stringhelper.h"

//C# TO C++ CONVERTER NOTE: Forward class declarations:
namespace Client::MirScenes::Dialogs { class FriendRow; }

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirNetwork;
using namespace Client::MirSounds;
namespace C = ClientPackets;

namespace Client::MirScenes::Dialogs
{
    class FriendDialog final : public MirImageControl
    {
    public:
        MirImageControl *TitleLabel, *FriendLabel, *BlacklistLabel;
        MirLabel *PageNumberLabel;
        MirButton *CloseButton, *PreviousButton, *NextButton;
        MirButton *AddButton, *RemoveButton, *MemoButton, *EmailButton, *WhisperButton;
        std::vector<FriendRow*> Rows = std::vector<FriendRow*>(12);

        std::vector<ClientFriend*> Friends = std::vector<ClientFriend*>();
    private:
        ClientFriend *SelectedFriend = nullptr;
        bool _tempBlockedTab = false;
        bool _blockedTab = false;

    public:
        int SelectedIndex = 0;
        int StartIndex = 0;
        int Page = 0;

        virtual ~FriendDialog()
        {
            delete TitleLabel;
            delete FriendLabel;
            delete BlacklistLabel;
            delete PageNumberLabel;
            delete CloseButton;
            delete PreviousButton;
            delete NextButton;
            delete AddButton;
            delete RemoveButton;
            delete MemoButton;
            delete EmailButton;
            delete WhisperButton;
            delete SelectedFriend;
        }

        FriendDialog();

    private:
        void UpdateDisplay();

    public:
        void Update(bool clearSelection = true);

        void UpdateRows();

        int FindSelectedIndex();

        void Hide() override;
        void Show() override;
    };
    class FriendRow final : public MirControl
    {
    public:
        ClientFriend *Friend;
        MirLabel *NameLabel, *OnlineLabel;

        bool Selected = false;

        virtual ~FriendRow()
        {
            delete Friend;
            delete NameLabel;
            delete OnlineLabel;
        }

        FriendRow();

    private:
        void FriendRow_BeforeDraw(std::any sender, EventArgs *e);

    public:
        void UpdateInterface();


    protected:
        void OnMouseEnter() override;
        void OnMouseLeave() override;

        void Dispose(bool disposing) override;
    };
    class MemoDialog final : public MirImageControl
    {
        //public MirImageControl TitleLabel;
    public:
        MirTextBox *MemoTextBox;
        MirButton *CloseButton, *OKButton, *CancelButton;

        ClientFriend *Friend;

        virtual ~MemoDialog()
        {
            delete MemoTextBox;
            delete CloseButton;
            delete OKButton;
            delete CancelButton;
            delete Friend;
        }

        MemoDialog();

        void Show() override;
    };
}
